<template>
	<view class="cu-form-group">
		<view class="title">{{label}}</view>
		<view class="tar flex1 fs12">
			<his-date-time @change="TimeChange" v-model="valueInside" :defaultValue="valueInside"></his-date-time>
		</view>
	</view>
</template>

<script>
	import com from '../../assets/js/com.js'
	import hisDateTime from '../biaofun-datetime-picker/biaofun-datetime-picker.vue'
	export default {
		name: "sdatetime",
		props: {
			value: {
				type:String,
				default:""
			},
			model: "",
			label: {
				type:String,
				default:"未设置"
			},
			placeholder: {
				type:String,
				default:""
			}
		},
		components:{hisDateTime},
		data() {
			return {
				valueInside: '',
				date: '',
				time: '00:00'
			}
		},
		methods: {

			TimeChange(e) {
				this.valueInside = e.f3
			},
			DateChange(e) {
				this.date = e.detail.value
			}
		},
		mounted() {
			this.valueInside = this.value
			let dateNow
			if (com.isbool(this.valueInside)) {
				dateNow = new Date(this.valueInside)
			} else {
				dateNow = new Date()
			}

			let date = com.getDate(dateNow)
			let time = com.getTime(dateNow)
			this.date = date
			this.time = time
		},
		watch: {
			value(curVal,oldVal){
				this.valueInside = curVal
			},
			valueInside(curVal, oldVal) {
				this.$emit('input', curVal)
			}
		}
	}
</script>

<style>
	.cu-form-group .title {
		min-width: calc(4em + 15px);
	}
</style>
